<h1 class="page-header">
    <small>卡券明细</small>
</h1>
<hr/>
<div class="panel panel-inverse" data-sortable-id="form-stuff-5">
    <div class="panel-heading">
        <h4 class="panel-title">明细查询</h4>
    </div>
    <div class="panel-body">
        <form id="memberForm" name="memberForm" method="post" class="form-inline">
            <div class="block clearfix" style="display: block;height: 45px;">
                <div class="form-group m-r-10">
                    <input type="hidden" class="form-control" name="EQ_uuid" value="${params.EQ_uuid}"
                           placeholder="导入uuid">
                    <input type="text" class="form-control" name="LIKE_mobile" value="${params.LIKE_mobile}"
                           placeholder="会员手机号">
                </div>
                <div class="form-group m-r-10">
                    <input type="text" class="form-control" name="EQ_groupId" value="${params.EQ_groupId}"
                           placeholder="分组ID">
                </div>
                <div class="form-group m-r-10">
                    <input type="text" class="form-control" name="LIKE_couponGroupName" value="${params.LIKE_couponGroupName}"
                           placeholder="分组名称">
                </div>
                <div class="form-group m-r-10">
                    <input type="text" class="form-control" name="EQ_couponId" value="${params.EQ_couponId}"
                           placeholder="券ID">
                </div>
                <div class="form-group m-r-10">
                    <input type="text" class="form-control" name="LIKE_couponName" value="${params.LIKE_couponName}"
                           placeholder="券名称">
                </div>
                <div class="form-group m-r-10">
                    <select class="form-control" name="LIKE_suitStoreIds" id="LIKE_suitStoreIds">
                        <option value="">适用店铺</option>
                        <#if storeList?has_content && storeList?exists>
                        <#list storeList as pf>
                            <option value="${pf.id}" <#if params.LIKE_suitStoreIds== pf.id> selected</#if>>${pf.name}</option>
                        </#list>
                        </#if>
                    </select>
                </div>
            </div>
            <div class="block clearfix" style="display: block;height: 45px;">
                <div class="form-group m-r-10">
                    <select class="form-control" name="EQ_storeId" id="EQ_storeId">
                        <option value="">使用店铺</option>
                        <#if storeList?has_content && storeList?exists>
                        <#list storeList as pf>
                        <option value="${pf.id}" <#if params.EQ_storeId== pf.id> selected</#if>>${pf.name}</option>
                        </#list>
                        </#if>
                    </select>
                </div>
                <div class="form-group m-r-10">
                    <select class="form-control" name="EQ_couponInfoStatus" id="EQ_couponInfoStatus">
                        <option value="">状态</option>
                        <option value="A" <#if params.EQ_couponInfoStatus== "A"> selected</#if>>未使用</option>
                        <option value="B" <#if params.EQ_couponInfoStatus== "B"> selected</#if>>已使用</option>
                        <option value="C" <#if params.EQ_couponInfoStatus== "C"> selected</#if>>已过期</option>
                        <option value="D" <#if params.EQ_couponInfoStatus== "D"> selected</#if>>已作废</option>
                        <option value="E" <#if params.EQ_couponInfoStatus== "E"> selected</#if>>未领取</option>
                     </select>
                </div>
                <div class="form-group m-r-10">
                    <button type="button" class="btn btn-sm btn-success m-r-5"
                            onclick="postDataByForm('backend/member/CouponinfoList','displayArea','memberForm')"><i class="fa fa-search"></i>查询
                    </button>
                    <button type="button" class="btn btn-sm btn-success m-r-5" onclick="exportExcel();"><i class="fa fa-sign-out"></i>导出Excel</button>
                    <button type="button" class="btn btn-sm btn-danger m-r-5" onclick="downLoad();"><i class="fa fa-download"></i>下载二维码</button>
                </div>
            </div>
        </form>
    </div>
</div>
<hr />
<div class="panel panel-inverse" data-sortable-id="table-basic-4">
    <div class="panel-heading">
        <div class="panel-heading-btn">
        </div>
        <h4 class="panel-title">已发放<span class="focus-num">${couponTotalDto.couponTotal}</span>张券；<span class="focus-num">${couponTotalDto.unUsedTotal}</span>张未使用；<span class="focus-num">${couponTotalDto.usedTotal}</span>张已使用；<span class="focus-num">${couponTotalDto.expireTotal}</span>张已过期；<span class="focus-num">${couponTotalDto.disableTotal}</span>张券已作废</h4>
    </div>
    <div class="panel-body">
        <table class="table table-striped table-bordered">
            <thead>
            <tr>
                <th>会员</th>
                <th>卡券类型</th>
                <th>卡券名称</th>
                <th>状态</th>
                <th>面额</th>
                <th>使用店铺</th>
                <th>使用时间</th>
                <th>最后操作时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <#if paginationResponse.content?has_content && paginationResponse.content?exists && paginationResponse.content?size gt 0>
            <#list paginationResponse.content as ct>
            <tr>
                <td><#if ct.name>${ct.name}<#else>--</#if></td>
                <td>
                    <#if ct.type == 'T' >
                    集次卡
                    <#elseif ct.type == 'P'>
                    预存卡
                    <#else>
                    优惠券
                    </#if>
                </td>
                <td>${ct.couponName}</td>
                <td>${ct.couponInfoStatusDesc}</td>
                <td>${ct.money}</td>
                <td><#if ct.storeName>${ct.storeName}<#else>不限</#if></td>
                <td><#if ct.usedTime>${ct.usedTime}<#else>--</#if></td>
                <td>${ct.updateTime}</td>
                <td>
                    <#if ct.couponInfoStatus == "A" || ct.couponInfoStatus == "E">
                    <a class="label label-success small-btn" href="javascript:confirmerCoupon('${ct.id}')"  title="手动核销"><i class="fa fa-adjust"></i>核销</a>
                    <a class="label label-danger small-btn" href="javascript:getConfirmData('确定作废${ct.mobile}的${ct.couponName}券？作废后用户端无法再看到此劵.注意：该操作不可撤回','${rc.contextPath}/backend/coupon/deleteUserCoupon/${ct.id}','displayArea')"><i class="fa fa-trash"></i>作废</a>
                    <#elseif ct.couponInfoStatus == "B">
                    --
                    <#else>
                    </#if>
                </td>
            </tr>
            </#list>
            <#else>
            <tr class="gradeA even" role="row">
                <td colspan="11" class="text-center">没有符合条件的数据！</td>
            </tr>
            </#if>
            </tbody>
        </table>
    </div>
</div>

<script language="JavaScript">
    function exportExcel() {
        var params = "";
        var inp =document.getElementsByTagName("input");
        for(var i=0;i<inp.length;i++){
            if(inp[i].value.length > 0){
                params += inp[i].name+"="+inp[i].value+"&"
            }
        }
       // alert(params);
        var sel =document.getElementsByTagName("select");
        for(var i=0;i<sel.length;i++){
            if(sel[i].value.length > 0){
                params += sel[i].name+"="+sel[i].value+"&"
            }
        }
        params+="temppara1=temppara1";
        window.location = "${rc.contextPath}/backend/member/exportCouponinfoList?" + params;
    }

    function downLoad() {
        var params = "";
        var inp =document.getElementsByTagName("input");
        for(var i=0;i<inp.length;i++){
            if(inp[i].value.length > 0){
                params += inp[i].name+"="+inp[i].value+"&"
            }
        }
        var sel =document.getElementsByTagName("select");
        for(var i=0;i<sel.length;i++){
            if(sel[i].value.length > 0){
                params += sel[i].name+"="+sel[i].value+"&"
            }
        }
        params+="temppara1=temppara1";
        window.location = "${rc.contextPath}/backend/member/exportCouponinfoList?" + params;
    }

    /**
     * 核销卡券
     * @param name
     */
    function confirmerCoupon(userCouponId) {
        //alterpage('${rc.contextPath}/backend/member/confirmerUserCouponPage/'+userCouponId, "核销卡券","500px","300px");
       getData('${rc.contextPath}/backend/member/confirmerUserCouponPage/'+userCouponId, "displayArea");
    }

</script>
<!-- 分页组件 -->
<!-- recordBean 分页查询结果Bean
     action 分页请求URL
     formName 分页需要的查询参数的表单名称 -->
<@sp.pagination recordBean=paginationResponse action="${rc.contextPath}/backend/member/CouponinfoList" formName="memberForm"/>
